home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
exclusiv.fr_
/
exclusiv.fr
Wrap
Text File
|
1995-07-06
|
5KB
|
178 lines
VERSION 4.00
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Non-User"
ClientHeight = 3150
ClientLeft = 2265
ClientTop = 1680
ClientWidth = 3405
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 3555
Left = 2205
LinkTopic = "Form1"
ScaleHeight = 3150
ScaleWidth = 3405
Top = 1335
Width = 3525
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "E&xit"
Height = 375
Left = 540
TabIndex = 5
Top = 2340
Width = 2295
End
Begin VB.CommandButton cmdClose
Caption = "&Close Database"
Enabled = 0 'False
Height = 375
Left = 540
TabIndex = 4
Top = 1860
Width = 2295
End
Begin VB.CommandButton cmdOpen
Caption = "&Open Database"
Height = 375
Left = 540
TabIndex = 3
Top = 1380
Width = 2295
End
Begin VB.Frame Frame1
BackColor = &H00C0C0C0&
Caption = "Data Sharing"
Height = 915
Left = 480
TabIndex = 0
Top = 300
Width = 2415
Begin VB.OptionButton optShared
BackColor = &H00C0C0C0&
Caption = "Open Shared"
Height = 195
Left = 180
TabIndex = 2
Top = 600
Width = 1935
End
Begin VB.OptionButton optExclusive
BackColor = &H00C0C0C0&
Caption = "Open Exclusive"
Height = 195
Left = 180
TabIndex = 1
Top = 300
Value = -1 'True
Width = 1995
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
' Declare the database at the form level; several routines need to access
' the variable to work with the database.
Dim db As DATABASE
Private Sub cmdOpen_Click()
Dim dbName As String
' Set up the error handler.
On Error GoTo OpenError
' Open the database. If the value of optExclusive is True, open the
' database for exclusive access. If optExclusive is False, open it
' for shared access.
dbName = BiblioPath() ' BiblioPath is a function in READINI.BAS
Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
' Set the form caption to indicate that the database is opened and show
' whether it's opened exclusively or for shared access.
Form1.Caption = IIf(optShared, "Sharing User", "Exclusive User")
' Toggle the open and close buttons so that the user can close the
' database.
cmdClose.Enabled = True
cmdOpen.Enabled = False
Exit Sub
OpenError:
Dim msg As String
If Err = 3356 Then
' Error 3356 occure when the user tries to open a database that's
' already open or when the user tries to open exclusively a database
' that 's already open exclusive or shared.
' Display an error message informing the user why the database cannot
' be opened.
If optShared Then
' The user tried to open the database shared. Someone else
' must have it open exclusively.
msg = "Another user has the database opened for exclusive use."
msg = msg & " You cannot open it right now."
Else
' The user tried to open the database exclusively. It's already
' open for another user.
msg = "Another user has the database open."
msg = msg & " You cannot open it exclusively right now."
End If
Else
' For all other errors, just display Visual Basic's message.
msg = Error(Err)
End If
MsgBox msg, vbExclamation
Exit Sub
End Sub
Private Sub cmdClose_Click()
' Close the database.
db.Close
' Toggle the command buttons so the user can reopen the database.
cmdOpen.Enabled = True
cmdClose.Enabled = False
' Change the status bar to indicate that no database is open.
Form1.Caption = "Non-User"
End Sub
Private Sub cmdExit_Click()
End
End Sub